# Contributor: Will Sinatra <wpsinatra@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libreswan
pkgver=4.6
pkgrel=1
pkgdesc="IPsec implementation for Linux"
url="https://libreswan.org/"
arch="all"
license="GPL-2.0-or-later"
depends="nss-tools iproute2"
provides="openswan"
options="!check" # no testsuite
makedepends="bison flex coreutils bash xmlto
	gmp-dev linux-pam-dev nss-dev unbound-dev libcap-ng-dev
	curl-dev nspr-dev bsd-compat-headers ldns-dev
	"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://download.libreswan.org/libreswan-$pkgver.tar.gz
	Makefile.inc.local"

# secfixes:
#   4.6-r0:
#     - CVE-2022-23094
#   3.32-r0:
#     - CVE-2020-1763
#   3.29-r0:
#     - CVE-2019-10155
#   3.28-r0:
#     - CVE-2019-12312

build() {
	cp $srcdir/Makefile.inc.local $builddir
	make WERROR_CFLAGS="" \
		INITDIR_DEFAULT=/etc/init.d \
		PREFIX=/usr \
		FINALBINDIR=/usr/libexec/ipsec \
		FINALLIBEXECDIR=/usr/libexec/ipsec \
		programs
}

package() {
	make FINALMANDIR=share/man \
		INITDIR_DEFAULT=/etc/init.d \
		PREFIX=/usr \
		DESTDIR="$pkgdir" \
		INSTCONFFLAGS=-m644 \
		FINALBINDIR=/usr/libexec/ipsec \
		FINALLIBEXECDIR=/usr/libexec/ipsec \
		install
}

sha512sums="
c1c3efd7665dee6caaf08cb5aa50fcd37c299acad4b62648284fdb04edd50ba8fc8d33a9fb210edaf2312697f8cd251f33a6b16587eb2cfefd1269b4482dd499  libreswan-4.6.tar.gz
36415fae9b6674d66b7728fbc1df4bb3c4fcb16f0bbe88ead1f23e553bb51a9deb288a8659a0050a3fb1e14c3dbb8fb8524e9ef48fb6842dc94b11b758349c58  Makefile.inc.local
"
